Update CWE-918 model coverage for Apache HttpClient execute sinks#21804
Update CWE-918 model coverage for Apache HttpClient execute sinks#21804
execute sinks#21804Conversation
Agent-Logs-Url: https://github.com/github/codeql/sessions/bd4fa112-dbc3-47e8-9cef-9b1b13c7e549 Co-authored-by: owen-mc <62447351+owen-mc@users.noreply.github.com>
Request sinks
|
(1) Please delete your current changes on this branch. (2) Please update java/ql/lib/ext/org.apache.http.client.model.yml to: (3) Please add tests for the models in that file. Look at the other SSRF tests in java/ql/test/query-tests/security/CWE-918/ApacheHttpSSRF.java for an example to follow. You will have to add stubs and add the path to them in the file java/ql/test/query-tests/security/CWE-918/options . Look at that file to see where the stubs should be located. You can look at existing stubs to see what they should be like. |
Agent-Logs-Url: https://github.com/github/codeql/sessions/3db201db-a1b5-4353-a94a-14a8d156dd3b Co-authored-by: owen-mc <62447351+owen-mc@users.noreply.github.com>
Done in 043ec85. I removed the previous fluent-only test/stub changes, updated Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Request sinksexecute sinks
owen-mc
left a comment
There was a problem hiding this comment.
Adds some missing sinks.
There was a problem hiding this comment.
Pull request overview
This PR expands CodeQL’s Java SSRF (CWE-918) coverage by modeling additional Apache HttpClient 4.x HttpClient#execute(...) overloads as request-forgery sinks, and adds a dedicated regression test plus stubs to exercise those overloads.
Changes:
- Added sink models for the full set of
org.apache.http.client.HttpClient#execute(...)overloads takingHttpHost/HttpUriRequest. - Added a new CWE-918 regression test and minimal stubs for
HttpClientandResponseHandler, wiring the stub directory into the test classpath. - Updated the
RequestForgery.expectedbaseline and added a Java pack change note describing the analysis impact.
Show a summary per file
| File | Description |
|---|---|
| java/ql/lib/ext/org.apache.http.client.model.yml | Adds request-forgery sink models for HttpClient.execute(...) overloads. |
| java/ql/test/query-tests/security/CWE-918/ApacheHttpClientExecuteSSRF.java | New regression test covering each newly modeled overload. |
| java/ql/test/stubs/apache-http-client-4.4.13/org/apache/http/client/HttpClient.java | Adds an HttpClient stub exposing the modeled execute(...) overloads. |
| java/ql/test/stubs/apache-http-client-4.4.13/org/apache/http/client/ResponseHandler.java | Adds a ResponseHandler stub required by HttpClient.execute(...) overloads. |
| java/ql/test/query-tests/security/CWE-918/options | Extends the test classpath to include the new Apache HttpClient stub directory. |
| java/ql/test/query-tests/security/CWE-918/RequestForgery.expected | Updates expected results/baseline to include new alerts and model listing changes. |
| java/ql/lib/change-notes/2026-05-07-apache-httpclient-ssrf-sinks.md | Documents the user-visible analysis improvement for Java SSRF queries. |
Copilot's findings
- Files reviewed: 6/7 changed files
- Comments generated: 1
| HttpHost host = new HttpHost(sink); | ||
| HttpRequest req = new BasicHttpRequest("GET", "/"); | ||
| HttpUriRequest uriReq = (HttpUriRequest) (Object) sink; | ||
| HttpContext context = null; | ||
| HttpClient client = null; | ||
| ResponseHandler<Object> handler = null; |
Replaces the earlier fluent-
Requestfocused changes with targeted SSRF model updates and regression tests fororg.apache.http.client.HttpClient#executesinks.What this addresses
java/ql/lib/ext/org.apache.http.client.model.ymlto cover all requestedrequest-forgerysink overloads forHttpClient.execute(...).// $ Sourceand// $ Alertexpectations).Model updates
HttpClient.execute(HttpHost, HttpRequest)HttpClient.execute(HttpHost, HttpRequest, HttpContext)HttpClient.execute(HttpHost, HttpRequest, ResponseHandler)HttpClient.execute(HttpHost, HttpRequest, ResponseHandler, HttpContext)HttpClient.execute(HttpUriRequest)HttpClient.execute(HttpUriRequest, HttpContext)HttpClient.execute(HttpUriRequest, ResponseHandler)HttpClient.execute(HttpUriRequest, ResponseHandler, HttpContext)Test coverage added
java/ql/test/query-tests/security/CWE-918/ApacheHttpClientExecuteSSRF.javaHttpClient.executeoverloads listed above.Stub + test configuration updates
java/ql/test/stubs/apache-http-client-4.4.13/org/apache/http/client/HttpClient.javajava/ql/test/stubs/apache-http-client-4.4.13/org/apache/http/client/ResponseHandler.javajava/ql/test/query-tests/security/CWE-918/optionsto include${testdir}/../../../stubs/apache-http-client-4.4.13.Replaced previous branch content
java/ql/test/query-tests/security/CWE-918/ApacheHttpFluentSSRF.javajava/ql/test/stubs/apache-http-fluent-4.5.14/org/apache/http/client/fluent/Request.javaExample from new test
Original prompt
Created from VS Code.